use cargo::ops::CompileOptions;
use cargo::core::MultiShell;
use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::find_project_manifest;
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
#[deriving(PartialEq,Clone,Decodable,Encodable)]
pub struct Options {
fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-compile; args={}", os::args());
- let root = match options.manifest_path {
- Some(path) => Path::new(path),
- None => try!(find_project_manifest(&os::getcwd(), "Cargo.toml")
- .map_err(|_| {
- CliError::new("Could not find Cargo.toml in this \
- directory or any parent directory",
- 102)
- }))
- };
+ let root = try!(find_root_manifest_for_cwd(options.manifest_path));
let env = if options.release {
"release"
use cargo::{execute_main_without_stdin};
use cargo::core::MultiShell;
use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::find_project_manifest;
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
#[deriving(PartialEq,Clone,Decodable,Encodable)]
pub struct Options {
fn execute(options: Options, _shell: &mut MultiShell) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-clean; args={}", os::args());
- let root = match options.manifest_path {
- Some(path) => Path::new(path),
- None => try!(find_project_manifest(&os::getcwd(), "Cargo.toml")
- .map_err(|_| {
- CliError::new("Could not find Cargo.toml in this \
- directory or any parent directory",
- 102)
- }))
- };
+ let root = try!(find_root_manifest_for_cwd(options.manifest_path));
ops::clean(&root).map(|_| None).map_err(|err| {
CliError::from_boxed(err, 101)
#[phase(plugin, link)]
extern crate hammer;
-use std::os;
use std::io::process::ExitStatus;
use cargo::ops;
use cargo::{execute_main_without_stdin};
use cargo::core::{MultiShell};
use cargo::util::{CliResult, CliError};
-use cargo::util::important_paths::find_project_manifest;
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
#[deriving(PartialEq,Clone,Decodable)]
struct Options {
}
fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- let root = match options.manifest_path {
- Some(path) => Path::new(path),
- None => try!(find_project_manifest(&os::getcwd(), "Cargo.toml")
- .map_err(|_| {
- CliError::new("Could not find Cargo.toml in this \
- directory or any parent directory",
- 102)
- }))
- };
+ let root = try!(find_root_manifest_for_cwd(options.manifest_path));
let mut compile_opts = ops::CompileOptions {
update: options.update,
#[phase(plugin, link)]
extern crate hammer;
-use std::os;
use std::io::process::ExitStatus;
use cargo::ops;
use cargo::core::{MultiShell};
use cargo::util;
use cargo::util::{CliResult, CliError, CargoError};
-use cargo::util::important_paths::find_project_manifest;
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
#[deriving(PartialEq,Clone,Decodable)]
struct Options {
}
fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
- let root = match options.manifest_path {
- Some(path) => Path::new(path),
- None => try!(find_project_manifest(&os::getcwd(), "Cargo.toml")
- .map_err(|_| {
- CliError::new("Could not find Cargo.toml in this \
- directory or any parent directory",
- 102)
- }))
- };
+ let root = try!(find_root_manifest_for_cwd(options.manifest_path));
let mut compile_opts = ops::CompileOptions {
update: options.update,
-use util::{CargoResult, human};
+use std::os::{getcwd};
+use util::{CargoResult, CliError, CliResult, human};
/// Iteratively search for `file` in `pwd` and its parents, returning
/// the path of the directory.
file, pwd.display())))
}
+/// Find the root Cargo.toml
+pub fn find_root_manifest_for_cwd(manifest_path: Option<String>) -> CliResult<Path> {
+ match manifest_path {
+ Some(path) => Ok(Path::new(path)),
+ None => match find_project_manifest(&getcwd(), "Cargo.toml") {
+ Ok(x) => Ok(x),
+ Err(_) => Err(CliError::new("Could not find Cargo.toml in this \
+ directory or any parent directory", 102))
+ }
+ }
+}
+
/// Return the path to the `file` in `pwd`, if it exists.
pub fn find_project_manifest_exact(pwd: &Path, file: &str) -> CargoResult<Path> {
let manifest = pwd.join(file);